package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.dto.KeepRecordPageDto;
import com.example.entity.matirx.KeepRecord;
import com.example.entity.vo.KeepRecordVo;
import com.example.exception.BaseException;
import com.example.mapper.KeepRecordMapper;
import com.example.service.KeepRecordService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class KeepRecordServiceImpl extends ServiceImpl<KeepRecordMapper, KeepRecord> implements KeepRecordService {

    @Autowired
    private KeepRecordMapper keepRecordMapper;

    @Override
    public Page<KeepRecordVo> pageRecord(KeepRecordPageDto recordPageDto) {
        PageHelper.startPage(recordPageDto.getPage(), recordPageDto.getPageSize());
        Page<KeepRecordVo> keepRecordVoPage = keepRecordMapper.pageKeepRecordVo(recordPageDto);
        return keepRecordVoPage;
    }

    @Override
    public void editStatus(Integer keepRecordId) {
        int i = keepRecordMapper.updateStatusById(2, keepRecordId);
        if (i<=0){
            throw new BaseException("划归历史保养失败！");
        }
    }
}
